#include <STC89C5xRC.H>
#include "timer0.h"
#include "INTRINS.H"

unsigned char keynum,ledmode;

void main()
{
	P2 = 0XFE;
	time0_init();
	while(1)
	{
		keynum=key();
		if(keynum)
		{
			if(keynum==1)
			{
				ledmode++;
				if(ledmode>=2)ledmode=0;
			}
		}
	}
}

void timer0_routine() interrupt 1
{
	static unsigned int t0count;
	TL0 = 0x66;		//设置定时初值
	TH0 = 0xFC;		//设置定时初值
	t0count++;
	if(t0count>=500)
	{
		t0count = 0;
		if(ledmode==0)
		{
			P2=_crol_(P2,1);
		}
		if(ledmode==1)
		{
			P2=_cror_(P2,1);
		}

	}
}